package _96JieShiQi;

import _96JieShiQi.impl.AndExpression;
import _96JieShiQi.impl.OrExpression;
import _96JieShiQi.impl.TerminalExpression;

/**
 * @Test: 解释器模式 测试类
 * @author: ZBoHang
 * @time: 2021/9/17 13:59
 */
class Test {

    public static Expression getMaleExp() {
        Expression robert = new TerminalExpression("Robert");
        Expression join = new TerminalExpression("John");
        return new OrExpression(robert, join);
    }
    public static Expression getMarriedAndWomanExp() {
        Expression julie = new TerminalExpression("Julie");
        Expression married = new TerminalExpression("Married");
        return new AndExpression(julie, married);
    }
    public static void main(String[] args) {
        Expression isMale = getMaleExp();
        Expression isMarriedAndWoman = getMarriedAndWomanExp();

        System.out.println("John是male吗 " + isMale.interpret("John"));
        System.out.println("Julie是marriedAndWoman吗" + isMarriedAndWoman.interpret("Married Julie"));
    }
}
